package vn.bk.hotel;

import java.util.ArrayList;


import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

import com.actionbarsherlock.app.SherlockFragment;

public class About extends SherlockFragment
{
  public View onCreateView(LayoutInflater paramLayoutInflater, ViewGroup paramViewGroup, Bundle paramBundle)
  {
    View localView = paramLayoutInflater.inflate(R.layout.about, paramViewGroup, false);
    ListView localListView = (ListView)localView.findViewById(R.id.list_about);
    ArrayList<DataList> localArrayList = new ArrayList<DataList>();
    localArrayList.add(new DataList(getActivity().getString(R.string.intro), getActivity().getString(R.string.intro_des)));
    localArrayList.add(new DataList(getActivity().getString(R.string.asses), getActivity().getString(R.string.asses_des)));
    localArrayList.add(new DataList(getActivity().getString(R.string.response), getActivity().getString(R.string.reponse_des)));
    localArrayList.add(new DataList(getActivity().getString(R.string.version), getActivity().getString(R.string.version_des)));
    localArrayList.add(new DataList(getActivity().getString(R.string.more_apps), ""));
    
    localListView.setAdapter(new ListSubAdapter(getActivity(), 0, localArrayList));
    localListView.setOnItemClickListener(new AdapterView.OnItemClickListener()
    {
      public void onItemClick(AdapterView<?> paramAnonymousAdapterView, View paramAnonymousView, int paramAnonymousInt, long paramAnonymousLong)
      {
        switch (paramAnonymousInt)
        {
        case 3:
        default:
          return;
        case 1:
          try
          {
            Intent localIntent3 = new Intent("android.intent.action.VIEW");
            localIntent3.setData(Uri.parse("market://details?id=vn.bk.hotel"));
            About.this.startActivity(localIntent3);
            return;
          }
          catch (Exception localException2)
          {
            Toast.makeText(About.this.getActivity(), "Need Google Market, or Google Play", Toast.LENGTH_SHORT).show();
            return;
          }
        case 2:
          Intent localIntent2 = new Intent("android.intent.action.SEND");
          localIntent2.setType("message/rfc822");
          localIntent2.putExtra("android.intent.extra.EMAIL", new String[] { "caotuandung@gmail.com" });
          localIntent2.putExtra("android.intent.extra.SUBJECT", About.this.getString(R.string.msg_subject));
          localIntent2.putExtra("android.intent.extra.TEXT", "");
          try
          {
            About.this.startActivity(Intent.createChooser(localIntent2, "Send mail..."));
            return;
          }
          catch (ActivityNotFoundException localActivityNotFoundException)
          {
            Toast.makeText(About.this.getActivity(), "There are no email clients installed.", Toast.LENGTH_SHORT).show();
            return;
          }
        case 4:
        }
        try
        {
          Intent localIntent1 = new Intent("android.intent.action.VIEW");
          localIntent1.setData(Uri.parse("market://search?q=pub:Semantic Innovation Group"));
          About.this.startActivity(localIntent1);
          return;
        }
        catch (Exception localException1)
        {
          Toast.makeText(About.this.getActivity(), "Need Google Market, or Google Play", Toast.LENGTH_SHORT).show();
        }
      }
    });
    return localView;
  }
}
class ListSubAdapter extends ArrayAdapter<DataList> {
    private ArrayList<DataList> allData;
    private LayoutInflater inflater;

    public ListSubAdapter(Context paramContext, int paramInt,
	    ArrayList<DataList> paramArrayList) {
	super(paramContext, paramInt, paramArrayList);
	this.inflater = ((LayoutInflater) paramContext
		.getSystemService(Context.LAYOUT_INFLATER_SERVICE));
	this.allData = paramArrayList;
    }

    public View getView(int paramInt, View paramView, ViewGroup paramViewGroup) {
	ViewHolder localViewHolder1 = new ViewHolder();
	if (paramView == null) {
	    paramView = this.inflater.inflate(R.layout.list_sub, null);
	    localViewHolder1.mainView = ((TextView) paramView
		    .findViewById(R.id.tv_main));
	    localViewHolder1.subView = ((TextView) paramView
		    .findViewById(R.id.tv_sub));
	    paramView.setTag(localViewHolder1);
	}
	DataList localDataList = (DataList) this.allData.get(paramInt);
	if (localDataList != null) {
	    ViewHolder localViewHolder2 = (ViewHolder) paramView.getTag();
	    localViewHolder2.mainView.setText(localDataList.getMain());
	    localViewHolder2.subView.setText(localDataList.getSub());
	}
	return paramView;
    }
}

class ViewHolder {
    TextView mainView;
    TextView subView;
}
